<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="num">
    <button id="btn">划分个位</button>
    <div id="num2"></div>
    <script>
        document.getElementById("btn").onclick = function() {
            var _num = document.getElementById("num").value;
            while (_num !== 0) {
                console.log("个位是" + _num % 10);
                _num = parseInt(_num / 10);
            }
        }
    </script>
</body>

</html>